<template>
  <div class="factory-purchase-list-page">
    <div class="page-header">
      <h2 class="page-title">工厂采购列表</h2>
      <el-button type="text" class="return-btn" @click="handleReturn">返回</el-button>
    </div>

    <!-- 采购列表表格 -->
    <el-table :data="purchaseList" border style="width: 100%; margin-top: 20px;">
      <el-table-column prop="purchaseDate" label="采购日期" sortable />
      <el-table-column prop="purchaseNo" label="采购单号" sortable />
      <el-table-column prop="vendorName" label="厂商名称" sortable />
      <el-table-column prop="purchaseBrand" label="采购品牌" sortable />
      <el-table-column prop="operator" label="经办人" sortable />
      <el-table-column prop="purchaseQuantity" label="采购数量" sortable />
      <el-table-column label="操作">
        <template #default>
          <el-button type="primary"  style="background-color: #f56c6c; border-color: #f56c6c;">明细</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页区域 -->
    <div class="pagination-area">
      <span class="total-info">共 {{ purchaseList.length }} 条 共 4 页</span>
      <el-pagination
        @current-change="handleCurrentChange"
        @size-change="handleSizeChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 30]"
        :page-size="pageSize"
        layout="prev, pager, next"
        :total="purchaseList.length"
      />
      <el-select v-model="pageSize" @change="handleSizeChange" placeholder="条数/页" style="width: 100px; margin-left: 10px;">
        <el-option label="10条/页" value="10" />
        <el-option label="20条/页" value="20" />
        <el-option label="30条/页" value="30" />
      </el-select>
      <span>跳至</span>
      <el-input v-model="jumpPage" type="number" style="width: 50px; margin: 0 5px;" />页
      <el-button type="primary"  style="background-color: #00b4b4; border-color: #00b4b4;">确定</el-button>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue';

// 采购列表数据
const purchaseList = ref([
  {
    purchaseDate: '2017.07.22',
    purchaseNo: '127878478237487',
    vendorName: '一平云端',
    purchaseBrand: '香奈儿',
    operator: '张三',
    purchaseQuantity: '79000'
  },
  {
    purchaseDate: '2017.07.22',
    purchaseNo: '127878478237487',
    vendorName: '一平云端',
    purchaseBrand: '香奈儿',
    operator: '李四',
    purchaseQuantity: '79000'
  },
  {
    purchaseDate: '2017.07.22',
    purchaseNo: '127878478237487',
    vendorName: '一平云端',
    purchaseBrand: '香奈儿',
    operator: '张武',
    purchaseQuantity: '100'
  },
  {
    purchaseDate: '2017.07.22',
    purchaseNo: '127878478237487',
    vendorName: '一平云端',
    purchaseBrand: '香奈儿',
    operator: '牛柳',
    purchaseQuantity: '100'
  }
]);

// 分页参数
const currentPage = ref(1);
const pageSize = ref(10);
const jumpPage = ref('');

// 分页方法
const handleCurrentChange = (val) => {
  currentPage.value = val;
  console.log('当前页：', val);
};

const handleSizeChange = (val) => {
  pageSize.value = val;
  console.log('每页条数：', val);
};

// 返回操作
const handleReturn = () => {
  console.log('返回');
};
</script>

<style scoped>
.factory-purchase-list-page {
  padding: 20px;
  background-color: #fff;
  min-height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  font-weight: 600;
  color: #333;
  margin: 0 0 20px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.return-btn {
  color: #666;
}

.pagination-area {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}

.total-info {
  color: #666;
}

.el-pagination {
  margin: 0;
}

.el-input {
  width: auto;
}

/* 明细按钮样式 */
.el-button--primary {
  background-color: #f56c6c;
  border-color: #f56c6c;
}

.el-button--primary:hover {
  background-color: #f54e4e;
  border-color: #f54e4e;
}
</style>